package com.hualan.sfzy.controller.system;

import com.hualan.sfzy.entity.system.Company;
import com.hualan.sfzy.service.system.CompanyService;
import com.hualan.sfzy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @ClassName CompanyController
 * @Description TODO
 * @Author Mindy
 * @Date 2025年07月11日 下午9:29
 * @Version 1.0
 */
@RestController
public class CompanyController {

    @Autowired
    private CompanyService companyService;

    @PostMapping("/company")
    public Result add(@RequestBody Company company) {
        companyService.add(company);
        return Result.success();
    }

    @DeleteMapping("/company/{id}")
    public Result remove(@PathVariable Integer id) {
        companyService.remove(id);
        return Result.success();
    }

    @DeleteMapping("/company")
    public Result removeBath(Integer[] ids) {
        companyService.removeBatch(ids);
        return Result.success();
    }

    @PutMapping("/company")
    public Result edit(@RequestBody Company company) {
        companyService.edit(company);
        return Result.success();
    }

    @GetMapping("/company/{id}")
    public Result findById(@PathVariable Integer id) {
        return Result.success(companyService.findById(id));
    }

    @GetMapping("/company/page")
    public Result findByPage(@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                             @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                             Company company) {
        return Result.success(companyService.findByPage(pageNum, pageSize, company));

    }

    @GetMapping("/company")
    public Result find() {
        return Result.success(companyService.find());
    }
}



























